<?php 
/**
* @author Oliver Leisalu, Inditel Meedia
* @package DomFg
* @subpackage Menu
*/
class DomFgMenu extends DomFgComponent {
	
	protected $id = 'menu';
	
	protected $items = array();
	
	public function addItem( DomFgMenuLink $link  ) {
		return $this->items[] = $link;
	}
	
	public function addLink( DomFgMenuLink $link  ) {
		return $this->addItem( $link );
	}
	public function render() {

		$menu = '[';
		foreach( $this->items as $link )
			$menu .= $link->parse();

		return '
				<script type="text/javascript">
					'.$this->id.' = new DomFgMenu("'.$this->id.'");
					'.$this->id.'.drawMenu( '.$menu.'], 0 )
				</script>';
	}
	
	public static function getDefaultChild() {
		return 'menuLink';
	}

}
?>
